<template>
    <el-menu
            router
            style="border-right: none;text-align: left"
            :default-active="defaultActived"
            :default-openeds="defaultOpened"
            :unique-opened="true"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b">
        <el-menu-item index="/dashboard">
            <v-icon name="tachometer-alt"></v-icon>
            <span slot="title">控制台</span>
        </el-menu-item>
        <el-menu-item index="/shop" v-show="type === 2">
            <v-icon name="store"></v-icon>
            <span slot="title">商城管理</span>
        </el-menu-item>
        <el-menu-item index="/category" >
            <v-icon name="tags"></v-icon>
            <span slot="title">类别管理</span>
        </el-menu-item>
        <el-menu-item index="/item" v-show="type === 1">
            <v-icon name="shopping-bag"></v-icon>
            <span slot="title">商品管理</span>
        </el-menu-item>
        <el-menu-item index="/order" >
            <v-icon name="file-alt"></v-icon>
            <span slot="title">订单管理</span>
        </el-menu-item>
        <el-menu-item index="/log" v-show="type === 2">
            <v-icon name="user"></v-icon>
            <span slot="title">系统日志</span>
        </el-menu-item>
    </el-menu>
</template>

<script>
    import {getLoginInfo} from "../../api/app";

    export default {
        data: () => {
            return {
                defaultOpened: [1],
                defaultActived: '/dashboard',
                type: 1,
            }
        },
        async created() {
            let res = await getLoginInfo();
            this.type = res['userInfo']['type'];
            this.type = Number.parseInt(this.type)
        }
    }
</script>

<style lang="less" scoped>


</style>
